home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 08 - 1992 / 08.01 Apr⁄May 92 / Microsecond Timer / MicrosecondTimer.h < prev    next >
Encoding:
C/C++ Source or Header  |  1991-08-05  |  1.5 KB  |  62 lines  |  [TEXT/KAHL]

  1. /*                        MicrosecondTimer.h                */
  2. /*
  3.  * Time measurement.
  4.  * Copyright © 1991 Martin Minow.  All Rights Reserved
  5.  *
  6. /*
  7.  * Definitions for the Millisecond timer
  8.  */
  9. #ifndef _H_MsecTimer
  10. #define _H_MsecTimer
  11.  
  12. #define MSEC_PER_TICK    1
  13.  
  14. typedef struct MicrosecondEpoch {
  15.     unsigned long    time;            /* Time of day    */
  16.     signed long        microsecond;    /* Residual        */
  17. } MicrosecondEpoch, *MicrosecondEpochPtr;
  18.  
  19. /*
  20.  * Initialize the clock -- call once when your
  21.  * application starts.
  22.  */
  23. OSErr        InitializeMicrosecondTimer(void);
  24. /*
  25.  * Cancel the clock -- this is called automatically
  26.  * when your application exits.
  27.  */
  28. void        CancelMicrosecondTimer(void);
  29. /*
  30.  * Return the current extended time value.
  31.  */
  32. void        GetEpoch(MicrosecondEpochPtr result);
  33. /*
  34.  * Compute the difference between two epoch's. The
  35.  * result is in deltaTime (in microseconds).
  36.  * deltaTime is positive if epoch2 is later than epoch1.
  37.  *
  38.  * Returns TRUE if the time can be represented in
  39.  * microseconds (less than 35 minutes difference). If
  40.  * it returns FALSE, deltaTime is likely to be garbage.
  41.  */
  42. Boolean    DeltaTime(
  43.         MicrosecondEpochPtr        epoch1,
  44.         MicrosecondEpochPtr        epoch2,
  45.         signed long                *deltaTime
  46.     );
  47. /*
  48.  * Format an epoch value as "hh:mm:ss.fraction"
  49.  */
  50. void EpochToString(
  51.         MicrosecondEpochPtr        epochPtr,
  52.         StringPtr                result
  53.     );
  54. /*
  55.  * Use an extended time value to adjust the
  56.  * local clock.  Unfortunately, we can only adjust
  57.  * the clock by an integral number of seconds.
  58.  */
  59. void AdjustClock(
  60.         signed long                adjustment
  61.     );
  62. #endif